import logging

import requests


class BaseAPI:

    def do_request(self, data: dict):
        if 'url' in data:
            return self._http_request(data)
        if 'RPC' == data.get("protocol").upper():
            return self._rpc_request(data)
        if 'TCP' == data.get("protocol").upper():
            return self._tcp_request(data)

    @staticmethod
    def _http_request(data):
        """
        data格式：{'protocol': None, 'method': None, 'url': None, 'json': None, 'param': {}}
        :param data:
        :return:
        """
        resp = requests.request(**data)
        return resp

    @staticmethod
    def _rpc_request(data):
        pass

    @staticmethod
    def _tcp_request(data):
        pass
